﻿﻿using System.Collections;
 using System.Collections.Generic;
 using BaseSyntax.Values.StringTest.Yaml.Configs;

 namespace BaseSyntax.Values.StringTest.Yaml.Parsers
{
	public class GameObjParser:IParser
	{

		public Dictionary<string, object> Parse(
			Dictionary<string, object> dUnity, 
			string fileId, 
			Dictionary<string, object> parent,
			Dictionary<string, object> dCorona
			)
		{
			Dictionary<string, object> dSingleCorona = new Dictionary<string, object>();
			dCorona[fileId] = dSingleCorona;
			
			dSingleCorona["children"] = new ArrayList();
			dSingleCorona["actions"] = new ArrayList();
			
			var dSingleUnity = dUnity[fileId] as Dictionary<string, object>;

			dSingleCorona["cType"] = CoronaMap.GetCoronaType("GameObject");

			if (dSingleUnity == null)
			{
				return dSingleCorona;
			}
			dSingleCorona["name"] = dSingleUnity["m_Name"];
			
			if (dSingleUnity.ContainsKey("m_Component"))
			{
				var d1 = dSingleUnity["m_Component"] as ArrayList;

				if (d1 != null)
				{
					foreach (object d1Value in d1)
					{
						var d2 = d1Value as Dictionary<string, object>;
						string fileId1 = (string)d2["fileID"];
						ParserEntrance.Parse(fileId1, dSingleCorona);
					}
				}
			}
			
			return dSingleCorona;
		}
	}
}